<template>
	<view class="store-container">
		<!-- 顶部导航栏 -->
		<view class="navbar">
			<view class="navbar-left" @click="goBack">
				<u-icon name="arrow-left" size="20" color="#333"></u-icon>
			</view>
			<view class="navbar-title">门店列表</view>
			<view class="navbar-right">
				<view class="action-icon">
					<u-icon name="more-dot-fill" size="20" color="#333"></u-icon>
				</view>
				<view class="action-icon">
					<u-icon name="minus" size="20" color="#333"></u-icon>
				</view>
				<view class="action-icon">
					<u-icon name="setting" size="20" color="#333"></u-icon>
				</view>
			</view>
		</view>

		<!-- 搜索栏 -->
		<view class="search-section">
			<view class="search-bar">
				<view class="search-icon">
					<u-icon name="search" size="20" color="#999"></u-icon>
				</view>
				<input 
					class="search-input" 
					placeholder="搜索门店" 
					v-model="searchKeyword"
					@input="onSearch"
				/>
			</view>
		</view>

		<!-- 附近门店标题 -->
		<view class="nearby-header">
			<text class="nearby-title">当前地址附近门店</text>
			<view class="reposition-btn" @click="reposition">
				<u-icon name="setting" size="16" color="#ff6b35"></u-icon>
				<text class="reposition-text">重新定位</text>
			</view>
		</view>

		<!-- 门店列表 -->
		<view class="store-list">
			<view 
				class="store-item" 
				v-for="(store, index) in filteredStores" 
				:key="index"
				@click="contactStore(store)"
			>
				<view class="store-left">
					<view class="store-icon">
						<view class="store-building">
							<view class="building-body"></view>
							<view class="building-sign">STORE</view>
						</view>
					</view>
				</view>
				<view class="store-middle">
					<text class="store-name">{{ store.name }}</text>
					<view class="store-hours">
						<u-icon name="clock" size="16" color="#666"></u-icon>
						<text class="hours-text">营业中 08:00 - 20:00</text>
					</view>
					<view class="store-location">
						<u-icon name="map-pin" size="16" color="#666"></u-icon>
						<text class="location-text">距您{{ store.distance }} {{ store.address }}</text>
					</view>
				</view>
				<view class="store-right">
					<view class="contact-btn" @click.stop="contactStore(store)">
						<u-icon name="phone" size="16" color="#ff6b35"></u-icon>
						<text class="contact-text">联系门店</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			searchKeyword: '',
			stores: [
				{
					name: '木兰',
					distance: '122.36km',
					address: '山西省晋城市泽州县太平仙社区居委会'
				},
				{
					name: 'd_station',
					distance: '592.90km',
					address: '天津市市辖区河东区区人民医院'
				},
				{
					name: '番禺门店',
					distance: '624.23km',
					address: '广东省广州市番禺区123'
				},
				{
					name: '海珠门店',
					distance: '625.15km',
					address: '广东省广州市海珠区456'
				},
				{
					name: '213',
					distance: '630.45km',
					address: '北京市市辖区东城区11111111111'
				},
				{
					name: '他认为一个热火让他',
					distance: '635.78km',
					address: '上海市市辖区浦东新区789'
				},
				{
					name: '天河门店',
					distance: '640.12km',
					address: '广东省广州市天河区101112'
				},
				{
					name: '越秀门店',
					distance: '645.89km',
					address: '广东省广州市越秀区131415'
				}
			]
		}
	},
	computed: {
		filteredStores() {
			if (!this.searchKeyword) {
				return this.stores
			}
			return this.stores.filter(store => 
				store.name.toLowerCase().includes(this.searchKeyword.toLowerCase()) ||
				store.address.toLowerCase().includes(this.searchKeyword.toLowerCase())
			)
		}
	},
	methods: {
		// 返回上一页
		goBack() {
			uni.navigateBack()
		},
		
		// 搜索门店
		onSearch() {
			// 搜索逻辑已在computed中处理
		},
		
		// 重新定位
		reposition() {
			uni.showToast({
				title: '正在重新定位...',
				icon: 'loading'
			})
			
			// 模拟定位过程
			setTimeout(() => {
				uni.showToast({
					title: '定位成功',
					icon: 'success'
				})
			}, 2000)
		},
		
		// 联系门店
		contactStore(store) {
			uni.showModal({
				title: '联系门店',
				content: `是否要联系${store.name}？`,
				success: (res) => {
					if (res.confirm) {
						uni.showToast({
							title: `正在拨打${store.name}电话`,
							icon: 'none'
						})
					}
				}
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.store-container {
	min-height: 100vh;
	background-color: #f8f9fa;
	position: relative;
}

.navbar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20rpx 30rpx;
	background-color: #fff;
	border-bottom: 1rpx solid #f0f0f0;
	
	.navbar-left {
		width: 40rpx;
		height: 40rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.navbar-title {
		font-size: 36rpx;
		font-weight: 600;
		color: #333;
	}
	
	.navbar-right {
		display: flex;
		gap: 20rpx;
		
		.action-icon {
			width: 40rpx;
			height: 40rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
}

.search-section {
	padding: 20rpx 30rpx;
	background-color: #fff;
	
	.search-bar {
		display: flex;
		align-items: center;
		background-color: #f8f9fa;
		border-radius: 25rpx;
		padding: 20rpx 30rpx;
		
		.search-icon {
			margin-right: 20rpx;
		}
		
		.search-input {
			flex: 1;
			font-size: 28rpx;
			color: #333;
			
			&::placeholder {
				color: #999;
			}
		}
	}
}

.nearby-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 30rpx;
	background-color: #fff;
	margin-bottom: 20rpx;
	
	.nearby-title {
		font-size: 32rpx;
		font-weight: 600;
		color: #333;
	}
	
	.reposition-btn {
		display: flex;
		align-items: center;
		padding: 12rpx 20rpx;
		background-color: #fff5f5;
		border-radius: 20rpx;
		border: 1rpx solid #ff6b35;
		
		.reposition-text {
			font-size: 24rpx;
			color: #ff6b35;
			margin-left: 8rpx;
		}
	}
}

.store-list {
	.store-item {
		display: flex;
		align-items: center;
		padding: 30rpx;
		background-color: #fff;
		margin-bottom: 2rpx;
		
		.store-left {
			margin-right: 20rpx;
			
			.store-icon {
				width: 60rpx;
				height: 60rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				
				.store-building {
					position: relative;
					width: 50rpx;
					height: 50rpx;
					
					.building-body {
						width: 100%;
						height: 100%;
						background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
						border-radius: 8rpx 8rpx 0 0;
						position: relative;
						
						&::before {
							content: '';
							position: absolute;
							top: 8rpx;
							left: 8rpx;
							right: 8rpx;
							bottom: 8rpx;
							background-color: rgba(255, 255, 255, 0.2);
							border-radius: 4rpx;
						}
						
						&::after {
							content: '';
							position: absolute;
							bottom: -8rpx;
							left: 50%;
							transform: translateX(-50%);
							width: 60rpx;
							height: 8rpx;
							background-color: #ff6b6b;
							border-radius: 0 0 4rpx 4rpx;
						}
					}
					
					.building-sign {
						position: absolute;
						top: -12rpx;
						left: 50%;
						transform: translateX(-50%);
						background-color: #fff;
						color: #ff6b35;
						font-size: 16rpx;
						font-weight: 600;
						padding: 4rpx 8rpx;
						border-radius: 4rpx;
						border: 1rpx solid #ff6b35;
						white-space: nowrap;
					}
				}
			}
		}
		
		.store-middle {
			flex: 1;
			
			.store-name {
				display: block;
				font-size: 32rpx;
				font-weight: 600;
				color: #333;
				margin-bottom: 12rpx;
			}
			
			.store-hours {
				display: flex;
				align-items: center;
				margin-bottom: 8rpx;
				
				.hours-text {
					font-size: 26rpx;
					color: #666;
					margin-left: 8rpx;
				}
			}
			
			.store-location {
				display: flex;
				align-items: flex-start;
				
				.location-text {
					font-size: 24rpx;
					color: #999;
					margin-left: 8rpx;
					line-height: 1.4;
					flex: 1;
				}
			}
		}
		
		.store-right {
			margin-left: 20rpx;
			
			.contact-btn {
				display: flex;
				align-items: center;
				padding: 12rpx 20rpx;
				background-color: #fff5f5;
				border-radius: 20rpx;
				border: 1rpx solid #ff6b35;
				
				.contact-text {
					font-size: 24rpx;
					color: #ff6b35;
					margin-left: 8rpx;
				}
			}
		}
	}
}
</style> 